GraalVM 21.0 VS Code Extensions Released

Jiří Sedláček
graalvm
Published in
6 min readJan 19, 2021

--

As a part of the GraalVM 21.0 release, we’re happy to announce the GraalVM Extension Pack for Visual Studio Code. While being a Technology Preview release, it already provides many features to boost your Java 8+, JavaScript, Python, Ruby, R, and Micronaut productivity in the VS Code environment.

The Extension Pack is immediately available on the Visual Studio Code Marketplace and ready to be installed right from your VS Code — just type GraalVM in the Extensions: Marketplace view, select the GraalVM Extension Pack and click the Install button. While installing, read further to learn what’s in:

GraalVM Extension Pack

The GraalVM Extension Pack contains three extensions: Apache NetBeans Language Server, GraalVM and Micronaut. The NetBeans extension is mostly a generic support for Java 8 and higher for VS Code, the GraalVM extension delivers all the GraalVM-specific features and the Micronaut extension makes it easier to work with the Micronaut framework, including the GraalVM native image generation using a single command. Let’s describe each of the extensions in details.

Apache NetBeans Language Server Extension

This is an extension by Apache Software Foundation with contributions from Oracle Labs which uses the Apache NetBeans engine to deliver support for Java 8 and higher in VS Code: code completion, hints, refactorings, go to definition, javadoc on hover, and full support for Maven and Gradle projects.

Support for Java 8+

The extension provides a Java 8+ debugger which is also capable of debugging polyglot calls to JavaScript, Python, Ruby or R when running on the GraalVM. Read the Apache NetBeans Extension for Visual Studio Code document by Apache to learn more about this extension.

While the extension delivers all these features just on its own, it works best when used together with the GraalVM Extension — see the next chapter.

The Apache NetBeans Language Server extension provides these Command Palette commands:

  • Java: Compile Workspace
  • GraalVM: Pause in Script

GraalVM Extension

This is an extension by Oracle Labs to make the VS Code a friendly and comfortable development environment for GraalVM users. It allows to easily download and manage multiple GraalVM installations and integrate them into the VS Code, and enables all the unique GraalVM scripting & polyglot features.

Once installed, the GraalVM extension creates a new Gr item in the Activity Bar and provides the corresponding GraalVM Side Bar. This is where the various GraalVM releases can be downloaded and installed on the local system. Alternatively, an existing local GraalVM installation can also be added to this view. Both GraalVM Community and Enterprise distributions are supported — note that even the GraalVM Enterprise is free for evaluation and development purposes.

Each GraalVM node in this view can be expanded to display the additional components available for the GraalVM installation. The components can be easily installed and uninstalled by a single click on the corresponding node action.

One of the GraalVM installations can be selected as the Active GraalVM installation. This configures the VS Code environment to use the Active GraalVM installation as the Java platform to run Java projects and sets up the Apache NetBeans Language Server for this platform.

Configuring Active GraalVM

In case additional language components are installed (Python, R, etc.), the Active GraalVM installation can also be selected as the runtime for that language. At this point the extension enables various features for the selected language like code completion etc., becomes the runtime for that language and adds support for debugging the language, including polyglot calls to other GraalVM languages.

To help users generate GraalVM native images from their Maven projects, the extension provides Command Palette command GraalVM: Add Maven Native Image Plugin. It configures the project’s pom.xml file to enable building a native executable directly with Maven using the mvn package command without having to run the native-image command as a separate step. Read the Native Image Maven Plugin documentation to get more details.

Tooling support for Java and GraalVM languages is available using the VisualVM bundled with the Active GraalVM installation. VisualVM is a Java and polyglot monitoring and troubleshooting tool providing the CPU and Memory profiler, heap viewer and many other features to analyze Java, JavaScript, Python, Ruby, R, and polyglot programs running on the GraalVM. VisualVM can be attached to the running project process using the Command Palette command VisualVM: Open Process in VisualVM.

Monitoring VS Code Project Using VisualVM

Not only related to GraalVM, the extension provides a handy Command Palette command Setup Proxy which helps to define the proxy server to be used within the VS Code environment.

The GraalVM extension provides these Command Palette commands:

  • GraalVM: Add Existing GraalVM
  • GraalVM: Add Maven Native Image Plugin
  • GraalVM: Download & Install GraalVM
  • GraalVM: Install GraalVM Component
  • GraalVM: Install R Language Server
  • GraalVM: Install Ruby Language Server
  • GraalVM: Refresh Installations
  • GraalVM: Remove GraalVM Installation
  • GraalVM: Set Active GraalVM Installation
  • GraalVM: Togle Code Coverage
  • GraalVM: Uninstall GraalVM Component
  • VisualVM: Open Process in VisualVM
  • Setup Proxy

Micronaut Extension

This is an extension by Oracle Labs to support the Micronaut framework in the VS Code development environment. The extension has been designed to cooperate with the GraalVM extension for a smooth Micronaut applications development, including debugging and building GraalVM native images.

Entrypoint to the Micronaut extension is the Micronaut Tools page which opens as soon as the extension is loaded or using the Command Palette command Micronaut: Show Micronaut Tools Page. From this page a new Micronaut project can be created or an existing one opened, and GraalVM native image of the current Micronaut project can be generated. Also links to the Micronaut documentation and guides are provided here.

Micronaut Tools Page

The extension provides two possibilities to create a new Micronaut project: using the Micronaut Launch service or using a local Micronaut CLI installation. Both options will generate a project set up to run using the currently Active GraalVM installation as configured in the GraalVM extension. This ensures smooth native image generation without any additional setup. Alternatively, external Java platform can be defined for the project where needed.

As long as the current Active GraalVM installation has its Native Image component installed, the GraalVM native image can be easily generated from the current Micronaut project using a single Command Palette command Micronaut: Build Native Image. There’s also a possibility to build the native image inside of a Docker container using the Micronaut: Build… command and selecting the appropriate build target.

The Micronaut extension provides these Command Palette commands:

  • Micronaut: Create Micronaut Project
  • Micronaut: Build…
  • Micronaut: Build Native Image
  • Micronaut: Show Micronaut Tools Page

To get more details on the features and instructions on using them, please select the desired extension in the Extensions: Marketplace view and read the extension Details page, or visit the extension home at GitHub: Apache NetBeans Language Server Extension, GraalVM Extension and Micronaut Extension.

All three described extensions are in their early development stages, many advanced features are currently being worked on or planned, and some bugs are waiting to be discovered yet. We’ll highly appreciate your feedback on the features you’re missing and issues you’re experiencing! Please let us know at GitHub by requesting a feature, filing a bug or discussing with us, or simply leave a comment below this article.

--

--

Jiří Sedláček
graalvm

VisualVM author. Oracle Labs member. Opinions are my own.